from core.basehandler import BaseHandler
from core.room import Room
from core.action import Action
from items.map import Map
from core.support import set_cutscene, get_game

class SixthFloor(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # add inventory items
        self.add_item(Map())
        
        # build list of actions
        self.add_action(Back)
        self.add_action(Forward)
    
    # return description of room.
    def get_description(self):
        return "The fire is spreading, so you need to move quickly!!"
    
    # return image of room
    def get_image(self):
        return 'sixth_floor.jpg'
    
    def is_passable(self):
        
        game = get_game()
        
        # does the player have a lit lamp?
        player = game.get_player()
        if 'map' in player.inventory:
            return True
                
        else:
            return False

class SixthFloorHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return SixthFloor

# define actions for this room

class Back(Action):
    def __init__(self):
        Action.__init__(self, "Back")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Return to the 3rd floor"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'stairs'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"

class Forward(Action):
    def __init__(self):
        Action.__init__(self, "Forward")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Head to Professor Wyners office"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'lubin_office'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
    def is_enabled(self):
        if self.room.is_passable():
            return True
        else:
            return False